#region Summary

// 
// Owner : JackieHan 
// 
// Solution : LearnSolution 
// 
// Project : JackieHan.NHibernate3.Repository
// 
// File : DictionaryKeyManyToManyRepisitory.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : Summary
// 
// History : 
//			2010-09-19 23:36:16	    Create 
// 

#endregion

#region Using

using System;
using System.Collections.Generic;
using JackieHan.NHibernate3.Domain;
using NHibernate;

#endregion

namespace JackieHan.NHibernate3.Repository
{
    /// <summary> 
    /// Summary
    /// </summary>
    public class DictionaryKeyManyToManyRepisitory
    {
        public void Save(IList<DictionaryKeyManyToMany> items)
        {
            using (ISession session = NHSessionFactory.SessionFactory.OpenSession())
            {
                using (ITransaction trans =session.BeginTransaction())
                {
                    try
                    {
                        foreach (DictionaryKeyManyToMany item in items)
                        {
                            session.SaveOrUpdate(item);
                           session.Flush();
                        }
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }
        }
    }
}